package cn.iocoder.yudao.module.handguard.dal.mysql.journalism;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.journalism.JournalismDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.admin.journalism.vo.*;

/**
 * 新闻管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface JournalismMapper extends BaseMapperX<JournalismDO> {

    default PageResult<JournalismDO> selectPage(JournalismPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<JournalismDO>()
                .eqIfPresent(JournalismDO::getNewsImg, reqVO.getNewsImg())
                .eqIfPresent(JournalismDO::getTitle, reqVO.getTitle())
                .eqIfPresent(JournalismDO::getContent, reqVO.getContent())
                .eqIfPresent(JournalismDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(JournalismDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(JournalismDO::getReleaseTime));
    }

    default List<JournalismDO> selectList(JournalismExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<JournalismDO>()
                .eqIfPresent(JournalismDO::getNewsImg, reqVO.getNewsImg())
                .eqIfPresent(JournalismDO::getTitle, reqVO.getTitle())
                .eqIfPresent(JournalismDO::getContent, reqVO.getContent())
                .eqIfPresent(JournalismDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(JournalismDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(JournalismDO::getReleaseTime));
    }

}
